package com.likejian.rabbit.simple;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.likejian.rabbit.RabbitConfig;
import com.likejian.rabbit.entity.User;

@Component
public class UserSender {

	@Autowired
	private AmqpTemplate rabbitTemplate;
	
	public void send(String name){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		User user = new User();
		user.setId(1L);
		user.setName(name + "_" + sdf.format(new Date()));
		this.rabbitTemplate.convertAndSend(RabbitConfig.SPRINGBOOT_RABBIT_USER_QUEUE, user);
	}
}
